package br.com.ufpr.sgp.pages.processo;

import org.apache.wicket.Page;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;

import br.com.sebrae.pr.sgp.entities.Processo;
import br.com.ufpr.util.base.Protected;

@Protected
public class ModalCadastrarProcesso extends ModalWindow {
    private static final long serialVersionUID = 3657380196159162100L;

    private IModel<Processo> processoModel = new CompoundPropertyModel<Processo>(new Processo());

    public ModalCadastrarProcesso(final String id, final PageReference pageReference) {
        super(id);
        setCookieName("modalCriarProcesso");

        setPageCreator(new ModalWindow.PageCreator() {
            private static final long serialVersionUID = -3744724126674530340L;

            public Page createPage() {
                return new CadastrarProcessoPage(ModalCadastrarProcesso.this, processoModel, pageReference);
            }
        });

        setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
            private static final long serialVersionUID = 5522402614264633246L;

            public void onClose(AjaxRequestTarget target) {
                ModalCadastrarProcesso.this.onClose(target);
            }
        });

        showUnloadConfirmation(false);
    }

    public void onClose(final AjaxRequestTarget target) {

    }

    public void setProcessoModel(IModel<Processo> processoModel) {
        this.processoModel = processoModel;
    }
    
    public IModel<Processo> getProcessoModel() {
	    return processoModel;
    }

}
